package com.scut.edu.wanyou.util.msg;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URLConnection;

import org.apache.mina.core.future.ConnectFuture;
import org.apache.mina.transport.socket.nio.NioSocketConnector;


import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;

/**
 * Description:异步下载类
 * DownLoadAsyncTask.java Create on 2012-7-1 下午12:40:19 
 * @author chenxc * @version 1.0
 * Copyright (c) 2012 Company,Inc. All Rights Reserved.
 */
public class MessageAsyncTask extends AsyncTask<String, Integer , String>
{
	
	private static final int CANCELLED = 101;
	private static final int NETWORK_ERROR = 102;
	ConnectFuture cf;
	String messageSend;
	Context context;
	Boolean cancelled = false;
	
	public MessageAsyncTask(ConnectFuture cf)
	{
		this.cf = cf;
	}
	
	@Override
	protected void onCancelled() {
		// TODO Auto-generated method stub
		super.onCancelled();
		cancelled = true;
	}

	/* 结尾工作
	 * non-Javadoc)
	 * @see android.os.AsyncTask#onPostExecute(java.lang.Object)
	 */
	@Override
	protected void onPostExecute(String result) {
		// TODO Auto-generated method stub
		
		super.onPostExecute(result);
	}

	/* 准备工作
	 * non-Javadoc)
	 * @see android.os.AsyncTask#onPreExecute()
	 */
	@Override
	protected void onPreExecute() {
		// TODO Auto-generated method stub
		super.onPreExecute();
	}

	@Override
	protected void onProgressUpdate(Integer... values) {
		// TODO Auto-generated method stub
		super.onProgressUpdate(values);
	}

	
	/* 后台任务
	 * (non-Javadoc)
	 * @see android.os.AsyncTask#doInBackground(Params[])
	 */
	
	private boolean cancelled()
	{
		return cancelled;
	}

	@Override
	protected String doInBackground(String... arg0) {
		// TODO Auto-generated method stub
		cf.getSession().write(arg0);
		return null;
	}
	
}
